<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
{block name="title"}<title>{$baseWebMsg.0.content}</title>{/block}
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1,maximum-scale=1.0, user-scalable=0,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />

<link rel="alternate icon" type="img/hengwang-1.png"
	href="__PUBLIC__/home/img/hengwang-1.png">
{block name="base-css"}
<link rel="stylesheet" href="__PUBLIC__/home/css/amazeui.css" />
<link rel="stylesheet" href="__PUBLIC__/home/css/style.css" />
<link rel="stylesheet" href="__PUBLIC__/home/css/reg.css" />
{/block}
</head>

<body>
	{block name="header"}
		
	{/block}
	<!-- 内容主体 -->
	<div id="container">
	{block name="body"}{/block}
	</div>
	<!-- /内容主体 -->
	{block name="footer"}
	{/block}
<div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1">
	<div class="am-modal-dialog modal-border-radius">
		<div class="am-modal-hd top-font">
			登 陆<a href="javascript: void(0)" class="am-close am-close-spin"
				data-am-modal-close>&times;</a>
		</div>
		<div class="am-modal-bd">
			<div class="reg-login">
				<div></div>
				<div></div>
			</div>
			<div class="reg-login-input">
				<input name="tel" type="tel" placeholder="请输入手机号"/>
				<input name="pwd" type="password" placeholder="请输入密码"/>
			</div>
			<div class="wag-msg">
				
			</div>
			<div class="reg-login-button">
				<button id='login_check'>登 陆</button>
				<button id='reg_button' data-am-modal="{target: '#doc-modal-2', closeViaDimmer: 0, width: 560, height: 592}">注册</button>
			</div>
		</div>
	</div>
</div>

<div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-2">
	<div class="am-modal-dialog modal-border-radius">
		<div class="am-modal-hd top-font">
			注 册<a href="javascript: void(0)" class="am-close am-close-spin"
				data-am-modal-close>&times;</a>
		</div>
		<div class="am-modal-bd">
			<div class="reg-login">
				<div></div>
				<div></div>
			</div>
			<div class="reg-login-input">
				<input name="tel" type="tel" placeholder="请输入手机号"/>
				<input name="pwd" type="password" placeholder="请输入密码"/>
				<input name="repwd" type="password" placeholder="再次请输入密码"/>
				<div class='get-reg-code'>
					<input name="vcode" type="text" placeholder="请输入验证码"/>
					<button id='btnSendCode'>获取验证码</button>
				</div>
			</div>
			<div class="wag-msg">
				
			</div>
			<div class="reg-login-button">
				<button id='reg_submit'>注册</button>
			</div>
		</div>
	</div>
</div>
</body>
{block name="base-js"}
<!--[if lt IE 9]>
<script src="__PUBLIC__/home/http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="__PUBLIC__/home/http://cdn.staticfile.org/modernizr/2.8.3/modernizr.js"></script>
<script src="__PUBLIC__/home/assets/js/amazeui.ie8polyfill.min.js"></script>
<![endif]-->

<!--[if (gte IE 9)|!(IE)]><!-->
<script src="__PUBLIC__/home/js/jquery.min.js"></script>
<!--<![endif]-->
<script src="__PUBLIC__/home/js/amazeui.min.js"></script>
<script src="__PUBLIC__/home/js/scroll.js"></script>
<script src="__PUBLIC__/home/js/custom.js"></script>
<script src="__PUBLIC__/home/js/amazeui.lazyload.min.js"></script>
{/block}
<script type="text/javascript">
	$('#reg_button').click(function(){
		$('#doc-modal-1').modal('close');
	})
	function isMobilePhone(obj){
		var partten = /^(0|86|17951)?(13[0-9]|15[012356789]|17[35678]|18[0-9]|14[57])[0-9]{8}$/;
		if(partten.test(obj)){
			return true ;
		}else{
			return false ;
		}
	}
	var InterValObj; //timer变量，控制时间
	var count = 60; //间隔函数，1秒执行
	var curCount;//当前剩余秒数
	function SetRemainTime() {
        if (curCount == 0) {                
            window.clearInterval(InterValObj);//停止计时器
            $("#btnSendCode").removeAttr("disabled");//启用按钮
            $("#btnSendCode").text("重新发送");
        }
        else {
            curCount--;
            $("#btnSendCode").text(curCount + "秒重发");
        }
    }
	$("#btnSendCode").click(function(){
		var tel=$("[name='tel']:eq(1)").val();
		if(isMobilePhone(tel)){
			curCount = count;
			$("#btnSendCode").attr("disabled", "true");
			$("#btnSendCode").text(curCount + "秒重发");	
			InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
			$.ajax({
				type:"get",
				url:"{:url('Home/getVcode')}",
				data:{type:5,telephone:tel},
				dataType:'json',
				success:function(data,status){
					if(status=='success'){
						$(".wag-msg").html();
						if(data.code==-1){
							tankuang('150',data.msg);
						}else if(data.code==0){
							tankuang('150','短息发送失败');
						}else if(data.code==1){
							tankuang('150','短息发送成功');
						}else if(data.code==3){
							tankuang('150',data.msg);
						}
					}
				}
			});
		}else{
			tankuang('150','手机格式错误');
		}
	})
	$("#reg_submit").click(function(){
		var tel=$("[name='tel']:eq(1)").val();
		var vcode=$("[name='vcode']").val();
		var pwd=$("[name='pwd']:eq(1)").val();
		var repwd=$("[name='repwd']").val();
		$('.wag-msg').html();
		if(!isMobilePhone(tel)){
			tankuang('150','手机格式错误');
			return;
		}else if(vcode.length=='0'){
			$('.wag-msg').html('验证码不能为空');
			return;
		}else if(pwd!=repwd){
			$('.wag-msg').html('两次密码输入不一致');
			return;
		}
		$("#reg_submit").attr("disabled", "true");
		$.ajax({
			type:"post",
			url:"{:url('Login/reg')}",
			data:{tel:tel,pwd:pwd,repwd:repwd,vcode:vcode},
			dataType:'json',
			success:function(data,status){
				if(status=='success'){
					$("#reg_submit").removeAttr("disabled");
					if(data.code==300){
						$('.wag-msg').html(data.msg);
					}else if(data.code==200){
						tankuang('150',data.msg);
						$('#doc-modal-2').modal('close');
						$('#doc-modal-1').modal('open');
					}
				}
			}
		});
	})
	$("[name='tel']:eq(1)").blur(function(){
		var tel=$("[name='tel']:eq(1)").val();
		if(tel.length>0){
			if(isMobilePhone(tel)){
				$.ajax({
					type:"get",
					url:"{:url('Login/isTelephone')}",
					data:{tel:tel},
					success:function(data,status){
						var data=JSON.parse(data);
						if(status=='success'){
							if(data.code==300){
								$('.wag-msg').html(data.msg);
							}else if(data.code==200){
								$('.wag-msg').html("<span style='color:#5eb95e'>"+data.msg+"</span>");
							}
						}
					}
				});
			}
		}
	})
	$('#doc-modal-1,#doc-modal-2').on('open.modal.amui', function(){
  		$('.wag-msg').html('');
	});
	//登陆
	$("#login_check").click(function(){
		var tel=$("[name='tel']:eq(0)").val();
		var pwd=$("[name='pwd']:eq(0)").val();
		$('.wag-msg').html();
		if(!isMobilePhone(tel)){
			tankuang('150','手机格式错误');
			return;
		}else if(pwd.length=='0'){
			$('.wag-msg').html('密码不能为空');
			return;
		}
		$("#reg_submit").attr("disabled", "true");
		$.ajax({
			type:"post",
			url:"{:url('Login/login')}",
			data:{tel:tel,pwd:pwd},
			dataType:'json',
			success:function(data,status){
				if(status=='success'){
					$("#reg_submit").removeAttr("disabled");
					if(data.code==300){
						$('.wag-msg').html(data.msg);
					}else if(data.code==200){
						tankuang_redirect('150',data.msg,data.url);
					}
				}
			}
		});
	})
	$('img.lazy').lazyload({
		effect : 'fadeIn',
	});
	$(function(){
		$("[name='{$controller.'-'.$action}']").addClass('hw-menu-active');
	})
</script>

</html>

